<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
 
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

?>

<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		
		if (form.name.value == '') {
			alert( "Please fill in a name." );
		} else {
			submitform( pressbutton );
		}
	}
</script>

<form action="index2.php" method="POST" name="adminForm">

	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname">Project: <?php echo $this->row->project_name;?></td>
		</tr>
	</table>

<?php
	$ptabs = new mosTabs( 0 );
	$ptabs->startPane( "com_leagueman" );
	$ptabs->startTab("General","General-page");
    ?>
	
		<table class="adminform">
			<tr>
				<td align="right" width="25%"><b>Projectname:</b></td>
				<td><input type="text" size="40" class="text_area" name="project_name" style="width:200px;" value="<?php echo $this->row->getName(); ?>"></td>
			</tr>
			<tr>
				<td align="right"><b>Category:</b></td>
				<td><?php $this->plugin("leagueman_list", "leagues", "project_league", $this->row->getLeague());?></td>
			</tr>
			<tr>
				<td align="right"><b>Season:</b></td>
				<td><?php $this->plugin("leagueman_list", "seasons", "project_season", $this->row->getSeason());?></td>
			</tr>
			<tr>
				<td align="right"><b>Type:</b></td>
				<td><?php $this->plugin("leagueman_list", "templates", "project_template", $this->row->getTemplate());?></td>
			</tr>
			<tr>
				<td align="right"><b>Responsible</b></td>
				<td><?php $this->plugin("leagueman_list", "users", "project_admin", $this->row->getAdmin() );?></td>
			</tr>
			<tr>
				<td align="right"><b>Minimum Round</b></td>
				<td><input type="text" size="3" class="text_area" style="text-align:center;" name="project_min_round"  value="<?php echo $this->row->project_min_round; ?>"></td>
			</tr>
			<tr>
				<td align="right"><b>Maximum Round</b></td>
				<td><input type="text" size="3" class="text_area" style="text-align:center;" name="project_max_round" value="<?php echo $this->row->project_max_round; ?>"></td>
			</tr>
			<tr>
				<td align="right"><b>Count of Chapters</b></td>
				<td><input type="text" size="3" class="text_area" style="text-align:center;" name="params[cnt_chapters]" value="<?php echo $this->row->getParam("cnt_chapters", 0);?>" /></td>
			</tr>
			<tr>
				<td align="right"><b>Support Groups</b></td>
				<td><?php echo mosHTML::yesnoRadioList('params[groups_supported]', '', $this->row->getParam("groups_supported", 0));?></td>
			</tr>
			<tr>
				<td align="right"><b>Groups</b></td>
				<td><input type="text"class="text_area" name="params[project_groups]" value="<?php echo $this->row->getParam("project_groups", "");?>" /></td>
			</tr>
		</table>
<?php
	$ptabs->endTab();
	$ptabs->startTab("Points","Points-page");
?>
		<table class="adminform">
			<tr>
				<td width="25%">&nbsp;</td>
				<td width="10%" align="center"><b>Victory</b></td>
				<td width="10%" align="center"><b>Tie</b></td>
				<td width="10%" align="center"><b>Defeat</b></td>
				<td width="45%">&nbsp;</td>
			</tr>
			<tr>
				<td><b>Points after regular Time:</b></td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_regular_time_v]" value="<?php echo $this->row->getParam("points_after_regular_time_v", "3"); ?>" />
				</td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_regular_time_t]" value="<?php echo $this->row->getParam("points_after_regular_time_t", "1"); ?>" />
				</td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_regular_time_d]" value="<?php echo $this->row->getParam("points_after_regular_time_d", "0"); ?>" />
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td align="right"><b>allow extra time</b></td>
				<td align="left" colspan="4"><?php echo mosHTML::yesnoRadioList('params[allow_extra_time]', '', $this->row->getParam("allow_extra_time", 0) );?></td>
			</tr>
			<tr>
				<td><b>Points after extra Time:</b></td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_extra_time_v]" value="<?php echo $this->row->getParam("points_after_extra_time_v", "3"); ?>" />
				</td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_extra_time_t]" value="<?php echo $this->row->getParam("points_after_extra_time_t", "1"); ?>" />
				</td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_extra_time_d]" value="<?php echo $this->row->getParam("points_after_extra_time_d", "0"); ?>" />
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td><b>Points after extra Time:</b></td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_penalty_v]" value="<?php echo $this->row->getParam("points_after_penalty_v", "3"); ?>" />
				</td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_penalty_t]" value="<?php echo $this->row->getParam("points_after_penalty_t", "1"); ?>" />
				</td>
				<td align="center">
					<input type="text" size="3" class="text_area" style="text-align:center" name="params[points_after_penalty_d]" value="<?php echo $this->row->getParam("points_after_penalty_d", "1"); ?>" />
				</td>
				<td>&nbsp;</td>
			</tr>
		</table>
<?php
	$ptabs->endTab();
	$ptabs->startTab("Leaguetable","Leaguetable-page");
?>
		<table class="adminform">
			<tr>
				<td width="50%" valign="top">
					<table width="100%">
						</tr>
							<td width="50%" align="right"><b>Type</b></td>
							<td align="left">
								<input type="text" class="text_area" name="params[type]" value="<?php echo $this->row->getParam("type", "2"); ?>" />
							</td>
						</tr>
						</tr>
							<td width="50%" align="right"><b>show Leaguetable</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[leaguetable]', '', $this->row->getParam("leaguetable", 0));?></td>
						</tr>
						</tr>
							<td width="50%" align="right"><b>use short names</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[shortnames]', '', $this->row->getParam("shortnames", 0));?></td>
						</tr>
						<tr>
							<td align="right"><b>show last ranking</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[last_ranking]', '', $this->row->getParam("last_ranking", 0));?></td>
						</tr>
						<tr>
							<td align="right"><b>show count matches</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_matches]', '', $this->row->getParam("show_cnt_matches", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Victories</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_v]', '', $this->row->getParam("show_cnt_v", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Victories after extra</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_v1]', '', $this->row->getParam("show_cnt_v1", 0));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Victories after penalty</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_v2]', '', $this->row->getParam("show_cnt_v2", 0));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Ties</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_t]', '', $this->row->getParam("show_cnt_t", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Defeats</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_d]', '', $this->row->getParam("show_cnt_d", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Defeats after extra</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_d1]', '', $this->row->getParam("show_cnt_d1", 0));?></td>
						</tr>
						<tr>
							<td align="right"><b>show Count Defeats after penalty</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_cnt_d2]', '', $this->row->getParam("show_cnt_d2", 0));?></td>
						</tr>
						<tr>
			      			<td align="right"><b>show results</b></td>
				    		<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_results]', '', $this->row->getParam("show_results", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show diff</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_diff]', '', $this->row->getParam("show_diff", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show points</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_points]', '', $this->row->getParam("show_points", 1));?></td>
						</tr>
						<tr>
							<td align="right"><b>show negative points</b></td>
							<td align="left"><?php echo mosHTML::yesnoRadioList('params[show_negative_points]', '', $this->row->getParam("show_negative_points", 0));?></td>
						</tr>
					</table>
				</td>
				<td width="50%" valign="top">
					<table width="100%">
						<tr>
							<td align="right">
								<b>Highlight Table</b><br/>
								<textarea cols="40" rows="10" name="params[colors]" class="text_area"><?php echo $this->row->getParam("colors", "");?></textarea>
							</td>
						</tr>
						<tr>
	    					<td align="right">
								<b>Example for Highlight Table with 18 teams</b><br/>
<pre>
1,5,#ff0000,Championsleague;
6,6,#ffff00,Qualifikation Championsleague;
7,9,#ff00ff,UEFA-Cup;
16,18,#ff0000,Absteiger;
</pre>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
<?php
	$ptabs->endTab();
	$ptabs->startTab("Excludes","Excludes-page");
?>
		<table class="adminlist">
			<tr>
				<th width="1%"></th>
				<th width="5%">Id</th>
				<th width="94%" class="title">Name</th>
			</tr>
		<?php
			
			$teams = $this->row->getTeams();
			$excludes = $this->row->getParam("excludes", array());
			
			$k = 0;
			foreach($teams AS $team){
				
				$k = 1 - $k;
				
				if(in_array($team->team_id, $excludes)){
					$checked = 'checked="checked"';
				} else{
					$checked = '';
				}
				
				?>
					<tr class="<?php echo "row$k";?>">
						<td><input type="checkbox" name="params[excludes][]" value="<?php echo $team->team_id;?>" <?php echo $checked; ?> /></td>
						<td><b><?php echo $team->team_id;?></b></td>
						<td><?php echo $team->team_name;?></td>
					</tr>
				<?php
			}
				
		?>
		</table>
<?php
	$ptabs->endTab();
	$ptabs->startTab("Eventtypes","Eventtypes-page");
?>
		<table class="adminlist">
			<tr>
				<th width="20"></th>
				<th width="20%" class="title">Name</th>
				<th width="80%" class="title">Playermap Association</th>
			</tr>
		<?php 
			
			$eventtypes = $this->row->getEventtypes();
			
			$k = 0;
			foreach($this->eventtypes AS $eventtype){
				
				$k = 1 - $k;
				
				$et = LM::getLMTable("Eventtype");
				$et->populate($eventtype);
				
				if(in_array($et->getID(), $eventtypes)){
					$checked = 'checked="checked"';
				} else{
					$checked = '';
				}
				
				?>
					<tr class="<?php echo "row$k";?>">
						<td><input type="checkbox" name="eventtypes[]" value="<?php echo $et->getID();?>" <?php echo $checked; ?> /></td>
						<td><?php echo $et->getName();?></td>
						<td><?php echo $et->getAssociation();?></td>
					</tr>
				<?php
			}
				
		?>
		</table>
<?php
	$ptabs->endTab();
	$ptabs->startTab("Integration","Integration-page");
?>
		<table class="adminform">			
			<tr>
				<td width="20%" align="right"><b>Content Category</b></td>
				<td width="80%"><?php $this->plugin("leagueman_list", "section_category", "params[section_category]", $this->row->getParam("section_category", "") );?></td>
			</tr>
			<tr>
				<td width="20%" align="right"><b>Forum Category</b></td>
				<td width="80%"><input type="text" name="params[forum]" value="<?php echo $this->row->getParam("forum", "");?>" /> <?php echo ($this->row->getParam("forum", 0) == 0) ? '<a href="#create" onClick="javascript:submitbutton(\'createforum\');">create Forum</a>' : "Forum created!";?></td>
			</tr>
			<tr>
				<td width="20%" align="right"><b>Forum Itemid</b></td>
				<td width="80%"><input type="text" name="params[forumitemid]" value="<?php echo $this->row->getParam("forumitemid", "");?>" /></td>
			</tr>
			<tr>
				<td width="20%" align="right"><b>Gallery Category</b></td>
				<td width="80%"><input type="text" name="params[gallery]" value="<?php echo $this->row->getParam("gallery", "");?>" /></td>
			</tr>
			<tr>
				<td width="20%" align="right"><b>Gallery Itemid</b></td>
				<td width="80%"><input type="text" name="params[galleryitemid]" value="<?php echo $this->row->getParam("galleryitemid", "");?>" /></td>
			</tr>
		</table>
<?php
	$ptabs->endTab();
	$ptabs->endPane();
?>

	<input type="hidden" name="project_id" value="<?php echo $this->row->getID(); ?>">
	<input type="hidden" name="option" value="com_leagueman">
	<input type="hidden" name="act" value="projects">
	<input type="hidden" name="task" value="">
	
</form>